package controller.converters.reprodutivo;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;

import model.vos.reprodutivo.Raca;
import controller.services.impl.reprodutivo.ImplRacaService;

public class RacaConverter implements Converter {

	public Object getAsObject(FacesContext context, UIComponent component,
			String value) throws ConverterException {
		if (value == null) {
			return null;
		}
		return new ImplRacaService().pesquisarPorId(Long.parseLong(value));
	}

	public String getAsString(FacesContext context, UIComponent component,
			Object object) throws ConverterException {
		if (object == null) {
			return null;
		}
		Raca c = (Raca) object;
		return c.getId().toString();
	}

}
